Skip to content

Update README with troubleshooting info#7070

Closed
bob-okeefe wants to merge 2 commits intoAzure:mainfrom
bob-okeefe:patch-1
Closed

Update README with troubleshooting info#7070
bob-okeefe wants to merge 2 commits intoAzure:mainfrom
bob-okeefe:patch-1

Conversation

@bob-okeefe
Copy link
Copy Markdown

Added troubleshooting information regarding azd init

Added troubleshooting information regarding azd init
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a troubleshooting note to the azure.coding-agent extension README to help users resolve errors when running azd coding-agent config by pointing out the need to run azd init first.

Changes:

  • Added additional troubleshooting guidance related to running azd init before configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment on lines +83 to +84
You might also get this error if you have not run `azd init` first. To fix this, run `azd init` and go through the setup wizard. After this is completed, you should be able to run `azd coding-agent config`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richardpark-msft , can we make the extension to return this as part of the error? or even make the extension to invoke azd init ?

Looking for a way to shift left this from happening to preventing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From talking with @bob-okeefe, it sounded like the steps he went through were:

  1. azd login
  2. Run the coding-agent extension
  3. Error back from AZD cred (internally) that says the refresh token is expired

So then he azd init'd and it worked.

Does azd init do something differently from azd login?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting.
It might make a difference if you were asked to pick a subscription - or if the azd init invoked the azd auth login

Do we have more details about the number 3? I what was trying to use the credential?

Any ideas @weikanglim ? -

But then, @richardpark-msft , there's not expectation from the extension around running azd init first? If not, we should not add this note and instead make this an issue/bug to investigate (try to repro).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was always asked to pick a subscription when I ran azd coding-agent config. I would choose my subscription and my repo. However when I got to the MI step and said to create a new MI it always failed. I was only able to resolve this after running azd init.

See attached.
image

When using debug I got this:
image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I only figured out that I had to run azd init because when I was using Copilot to troubleshoot this it suggested running azd env set AZURE_SUBSCRIPTION_ID . When I did this I got this error:

ERROR: no project exists; to create a new project, run azd init

After the azure.yml file was created I was able to run azd coding-agent config successfully

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently those errors are coming from when I call into the 'azd' PromptClient/PromptServiceClient:

I was wondering, at first, if perhaps I was messing up some subscription or passing in a bad credential, but this is within 'azd' itself.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then, @richardpark-msft , there's not expectation from the extension around running azd init first? If not, we should not add this note and instead make this an issue/bug to investigate (try to repro).

There isn't - I remember us talking about this. I don't use any azd logic to detect or use any project, so it should be safe.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you happen to have subscriptions across multiple tenants? I wonder if doing azd auth login --tenant <tenant-id> would've helped in this case. It's odd you still got an expired token error right after running azd auth login.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you ended up running azd env set AZURE_SUBSCRIPTION_ID xxxxxx ?
If yes, that's how it was fixed.
You had to run azd init ... but only to be able to run azd env set ... - to have an azd env where to set the sub-id.

A similar approach is to set AZURE_SUBSCRIPTION_ID as system env var (not at azd's env) and that would also work.

The issue is that azd is trying to use a token for the wrong tenant. When you set the sub-id, azd resolves the right tenant where that sub belongs to.

Even thought the extension is asking for a subscription, azd is not using the response to use that sub/tenant for the following events - instead it is using the credential provider which resolves to use a different token.
We need to make the extension to use the subId selected to re-set the credential provider - I'll see if that can be done (time to chat to the AI ...) - I'll be back to you...

Copy link
Copy Markdown
Member

@vhvb1989 vhvb1989 Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the hypothesis — the extension uses Subscription.TenantId (resource tenant) instead of Subscription.UserTenantId (user access tenant) when creating the AzureDeveloperCLICredential. For multi-tenant/guest users these differ, causing "refresh token expired" errors.

Filed #7077 with fix at #7078.

Copy link
Copy Markdown
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Code Review — PR #7070

Thanks for surfacing this user pain point! The troubleshooting note is helpful.

One thing to note: the review thread identified the root cause as a tenant ID mismatch in the extension (using Subscription.TenantId instead of Subscription.UserTenantId). The azd init workaround helps because it sets AZURE_SUBSCRIPTION_ID. Once the underlying bug is fixed, this note may need updating.

Overall Assessment: Approve

@rajeshkamal5050
Copy link
Copy Markdown
Contributor

@vhvb1989 should we closse this PR in favor of #7080 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants